package com.cloudkinto.appletController.stock;


import com.cloudkinto.appletservice.stock.AppletStockRecordService;
import com.cloudkinto.base.BaseController;
import com.cloudkinto.common.annotations.UserSessionRequired;
import com.cloudkinto.common.web.PageResult;
import com.cloudkinto.common.web.SingleResult;
import com.cloudkinto.service.stock.StockRecordService;
import com.cloudkinto.service.stock.vo.record.StockRecordPageRes;
import com.cloudkinto.service.stock.vo.record.StockRecordSendReq;
import io.swagger.annotations.*;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 张永远
 * @since 2020-06-10
 */
@RestController
@Api(tags = "小程序库存管理模块")
@RequestMapping("/api/applet/stockRecord")
public class AppletStockRecordController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(AppletStockRecordController.class);

    @Autowired
    private AppletStockRecordService service;


//    @GetMapping("/{id}")
//    @ApiOperation(value = "根据id查看详情", notes = "根据id查看详情")
//    public SingleResult detail(@PathVariable("id") Long id) {
//        return SingleResult.success("查询成功",service.detail(id));
//    }


    @UserSessionRequired
    @GetMapping("/listPage")
    @ApiOperation(value = "查询（分页）", notes = "查询（分页）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyword", value = "模糊搜索")})
    @ApiResponses({@ApiResponse(code = 200, message = "", response = StockRecordPageRes.class)})
    public PageResult<StockRecordPageRes> listPage(String current, String pageSize, String keyword) {
        Long companyId = getCompanyId();

        Map<String, String> map = new HashMap<>();
        map.put("keyword", keyword);
        map.put("companyId", companyId + "");
        map.put("current", current);
        map.put("pageSize", pageSize);
        return service.getListPage(map);
    }


}

